
<!--<footer th:include="include/common/common :: zTreeJSSource"></footer>-->
<footer th:fragment="zTreeUserFooter">
    <!--<script>
        var initOptions = {
            title:'',   //zTree页面 title
            url:'',     //nodes 请求地址
            echoId:'',  //回显元素id
            excludeCode:'', //排除节点ID
            isShowCode:'false',   //是否显示节点代码 默认不显示
            canSelectRoot:true,     //根节点 是否允许选择，默认可选
            canSelectParent:true    //父节点 是否允许选择，默认可选
        };

        /**
         * 系统参数初始化
         * @param userOptions 用户参数
         */
        function intiOption(userOptions){
            $.extend(true, initOptions, userOptions);
        }

        // zTree 的数据属性，深入使用请参考 API 文档（zTreeNode 节点数据详解）
        var nodes = [];

        function zTreeOpen(options) {
            intiOption(options);
            $("#zTreeTitle").empty();
            $("#zTreeTitle").append(initOptions.title);
            getNodes();
            loadTree();
            $(".modal-bg").css("display" , "block");
            $(".modal-show").css("display" , "block");
        };


        function getNodes() {
            var excludeCodeVal = $("#" + initOptions.excludeCode).val();
            var excludeCode = excludeCodeVal != '' && excludeCodeVal != undefined?"excludeCode=" + excludeCodeVal:'';
            var isShowCode = initOptions.isShowCode != '' || initOptions.isShowCode != undefined?"isShowCode=" + initOptions.isShowCode:'';
            // var url = initOptions.url + "?excludeCode=" + excludeCode + "&isShowCode=" + initOptions.isShowCode;
            var url = initOptions.url;
            if (isNotEmpty(excludeCode) && isNotEmpty(isShowCode)){
                url = url + "?" + excludeCode + "&" + isShowCode;
            }else if (isNotEmpty(excludeCode)){
                url = url + "?" + excludeCode;
            }else if (isNotEmpty(isShowCode)){
                url = url + "?" + isShowCode;
            }
            $.ajax({
                type:"get",
                url:url,
                dataType:'json',
                async:false,
                success:function (result) {
                    if (isNotEmpty(result)){
                        nodes = result;
                    }
                },
                error:function () {

                }
            });
        };

        var zTreeObj;
        // zTree 的参数配置，深入使用请参考 API 文档（setting 配置详解）
        var setting = {
            check: {
                enable: true//checkbox
            },
            view: {
                nameIsHTML: true, //允许name支持html
                selectedMulti: false
            },
            edit: {
                enable: false,
                editNameSelectAll: false
            },
            // 回调定义
            callback:{
                // 鼠标点击事件的回调函数
                onClick:zTreeOnClick
            },
            // zTree data格式定义
            data:{
                keep:{
                    leaf:true,
                    parent:true
                },
                key:{
                    isParent:"treeLeaf"
                },
                simpleData:{
                    enable:true,
                    idKey:"id",
                    pIdKey:"pId",
                    rootPid:"0"
                }
            }
        };


        //zTree 节点单击回调函数

        function zTreeOnClick(event, treeId, treeNode) {
            $("#" + initOptions.echoId + "Code").val(treeNode.id);
            $("#" + initOptions.echoId + "Name").val(treeNode.name);
            reloadTreePanelValue(treeNode.id);
            closePanel();
        };

        /**
         * 生成 新代码 & 排序序号
         * @param parentCode
         */
        function reloadTreePanelValue(parentCode){
            var excludeCode = $("#" + initOptions.excludeCode).val();
            var data = {parentCode:parentCode,id:excludeCode};
            var url = initOptions.url.replace("treeData" , "createNextNode");
            $.ajax({
                type:"POST",
                url:url,
                dataType:"JSON",
                cache: false,
                headers : {
                    'Content-Type' : 'application/json;charset=utf-8'
                },
                data:JSON.stringify(data),
                success:function (result) {
                    if (isNotEmpty(result)){
                        var _treeSort = result.treeSort;
                        var _treeCode = result.treeCode;
                        var sortElement = $("#treeSort");
                        if (isNotEmpty(sortElement)){
                            $("#treeSort").val(_treeSort);
                        }
                        var treeCodeElement = $("#treeCode");
                        if (isNotEmpty(treeCodeElement)){
                            $("#treeCode").val(_treeCode);
                        }
                    }
                },
                error:function () {

                }

            });
        };

        $(function () {
            //关闭按钮
            $("#closeBtn").on("click" , function () {
                // 调用 activeClose 标签的 鼠标单击事件
                $("#activeClose").click();
            });

            $("#activeClose").on("click" , function () {
                closePanel();
            });

            $("#activeClean").on("click" , function () {
                $("#" + initOptions.echoId + "Name").val("");
                reloadTreePanelValue();
                $("#activeClose").click();
            });
        });



        function closePanel() {
            $(".modal-bg").css("display" , "none");
            $(".modal-show").css("display" , "none");
        };


        function loadTree() {
            //搜索框
            $("#searchBtn").on("click" , function () {
                fuzzSearch('treePanel','#searchInput',null,true); //初始化模糊搜索方法
            });
            //zTree加载
            zTreeObj = $.fn.zTree.init($("#treePanel"), setting, nodes);
            zTreeObj.expandAll(true);
            fuzzSearch('treePanel','#searchInput',null,true); //初始化模糊搜索方法
        };
    </script>-->
</footer>

<div class="modal-bg" th:fragment="zTreeMask"></div>

<!-- 模态框（Modal） -->
<div class="modal-show" th:fragment="zTreePanel">
    <div class="modal-dialog" style="width: 300px;height: 480px;">
        <div class="modal-content">
            <!-- Top 标题-->
            <div class="layui-layer-title" id="zTreeTitle" style="cursor: move"></div>

            <span class="layui-layer-setwin">
                <a class="layui-layer-ico layui-layer-close layui-layer-close1" id="closeBtn" href="javascript:void(0);"></a>
            </span>

            <!-- Middle 内容区-->
            <div class="layui-layer-content" style="overflow: auto;">
                <div class="treeSearchInput" id="search" style="display: block">
                    <label for="searchInput">关键字：</label>
                    <input type="text" id="searchInput" maxlength="50" class="empty"/>
                    <button class="btn" id="searchBtn" >搜索</button>
                </div>
                <div id="treePanel" class="ztree"></div>
            </div>

            <div class="modal-footer layui-layer-btn">
                <button type="button" class="btn btn-default" data-dismiss="modal" id="activeClose">关闭
                </button>
                <button type="button" class="btn btn-warning" id="activeClean">
                    清除
                </button>
            </div>

        </div>
        <!-- /.modal-content -->
    </div>
</div>